package com.lavida.project.system.goods.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lavida.project.system.goods.domain.Goods;
import com.lavida.project.system.goods.mapper.GoodsMapper;
import com.lavida.project.system.goods.mapper.SubGoodsMapper;

@Service
public class GoodsServiceImpl implements GoodsService{
	@Autowired
	private GoodsMapper goodsMapper;
	
	@Autowired
	private SubGoodsMapper subGoodsMapper;
	
	@Override
	public List<Goods> selectGoods(Goods goods) {
		return goodsMapper.selectGoods(goods);
	}
	@Override
	public void insertGoods(Goods goods) {
		// TODO Auto-generated method stub
		goodsMapper.insertGoods(goods);
	}
	@Override
	public void deleteGoods(int[] ids) {
		// TODO Auto-generated method stub
		for (int id:ids) {
			//主表删除操作时，子表数据先删除，在删除主表数据，不然的会报找不主表id这个异常的错误
			goodsMapper.deleteGoods(id);
		}
	}
	@Override
	public Goods getGoods(int id) {
		// TODO Auto-generated method stub
		return goodsMapper.getGoods(id);
	}
	@Override
	public void updateGoods(Goods goods) {
		// TODO Auto-generated method stub
		goodsMapper.updateGoods(goods);
	}
}
